FROM pytorch/pytorch:2.8.0-cuda12.8-cudnn9-runtime

# 设置环境变量
ENV PYTHONUNBUFFERED=1 \
    PYTHONDONTWRITEBYTECODE=1 \
    PIP_NO_CACHE_DIR=1 \
    PIP_BREAK_SYSTEM_PACKAGES=1 \
    MKL_THREADING_LAYER=GNU \
    OMP_NUM_THREADS=1 \
    TF_CPP_MIN_LOG_LEVEL=3

# 安装系统依赖
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
    gcc git zip unzip wget curl htop libgl1 libglib2.0-0 libsm6 && \
    apt-get clean && rm -rf /var/lib/apt/lists/*

# 设置工作目录
WORKDIR /app

# 复制 Flask 项目到容器中
COPY . /app

# 安装 Python 依赖
RUN pip install --upgrade pip && \
    pip install -r requirements.txt

# 暴露 Flask 默认端口
EXPOSE 5000

# 使用 gunicorn 启动 Flask 服务
CMD ["gunicorn", "-b", "0.0.0.0:5000", "app:app"]
